package com.itheima.server.controller;

import com.itheima.domain.mongo.RecommendUser;
import com.itheima.domain.vo.RecommendUserQueryVo;
import com.itheima.server.service.TanhuaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author 阿鹏
 * @date 2021/1/26 22:35
 */
@RestController
@RequestMapping("/tanhua")
public class TanhuaController {

    @Autowired
    private TanhuaService service;

    @GetMapping("/todayBest")
    public ResponseEntity todayBest() {
        return service.todayBest();
    }

    @GetMapping("/recommendation")
    public ResponseEntity findRecommendation(RecommendUserQueryVo queryVo) {
        return service.findRecommendation(queryVo);
    }

    @GetMapping("/{id}/personalInfo")
    public ResponseEntity getPersonalInfo(@PathVariable("id") long userId) {
        return service.getPersonalInfo(userId);
    }

    @GetMapping("/strangerQuestions")
    public ResponseEntity findStrangerQuestions(Long userId) {
        return service.findStrangerQuestions(userId);
    }

    @PostMapping("/strangerQuestions")
    public ResponseEntity replyStrangerQuestions(@RequestBody Map map) {
        Long userId = Long.parseLong(map.get("userId").toString());
        String reply = (String) map.get("reply");
        return service.replyStrangerQuestions(userId, reply);
    }

    @GetMapping("/search")
    public ResponseEntity searchNear(@RequestParam(required = false) String gender,
                                     @RequestParam(defaultValue = "2000") Integer distance) {
        return service.searchNear(gender, distance);
    }

    @GetMapping("cards")
    public ResponseEntity findCards() {
        return service.findCards();
    }

    @GetMapping("{id}/love")
    public ResponseEntity likeUser(@PathVariable("id") Long likeUserId) {
        return service.likeUser(likeUserId);
    }

    /**
     * 不喜欢
     *
     * @param likeUserId
     * @return
     */
    @GetMapping("{id}/unlove")
    public ResponseEntity disLikeUser(@PathVariable("id") Long likeUserId) {
        return service.disLikeUser(likeUserId);
    }

}



